import java.io.*;
import java.util.*; 

import javax.crypto.EncryptedPrivateKeyInfo;

public class AnalyzeDir3 {

	public static void main(String[] args) throws Exception{
		File dir= new File("tmp");
		if(!dir.exists())
			return;
		
		File dir2= new File("tmp2");
		if(!dir2.exists())
			dir2.mkdirs();
		
		File[] farr= dir.listFiles();
		for(File f1: farr){
			if(f1.isDirectory())
				continue;
			
			
			FileInputStream fis=new FileInputStream(f1);
			BufferedReader br = new BufferedReader(new InputStreamReader(fis));
			String line="";
			StringBuffer sb= new StringBuffer("");
			while((line=br.readLine())!= null){
				String _t=Crypto.getInstance().decrypt(line);
				sb.append("\n"+_t);
				
			}
			br.close();

			
			PrintWriter pw = new PrintWriter("tmp2/"+f1.getName());
			BufferedReader br1=new BufferedReader(new StringReader(sb.toString())); 
			while((line=br1.readLine())!= null){
				String tmp=line.replaceAll(" d=\"[0-9]+\"", "").replaceAll(".* f=\"[0-9]+\"/>", "").trim();
				if(tmp.length()>0)
				pw.println(Crypto.getInstance().encrypt(tmp));
				
			}
			pw.close();
			br1.close();
		}
		

	}
	
	
	
	public static String encrypt(String str){
		return Crypto.getInstance().encrypt(str);
	}
	public static String decrypt(String str){
		return Crypto.getInstance().decrypt(str);
	}


}
